<template>
    <div class="repair">
        <van-form show-error scroll-to-error label-width="25vw" @submit="onSubmit" @failed="onFailed">
            <div class="tip">请仔细核对逝者和联系人信息，确认信息真实、准确、有效。</div>
            <MyTitle>逝者信息</MyTitle>
            <van-field
                v-model="formData.cr_ex1"
                :readonly="isReadonly"
                required
                center
                name="cr_ex1"
                label="逝者姓名"
                placeholder="逝者姓名"
                :rules="[{ required: true, message: '请填写逝者姓名' }]"
            >
                <!-- <template v-if="!isReadonly" #button>
                    <Uploader v-model="formData.gsy_ex6" uploadField="gsy_ex6">
                        <van-button size="small" icon="plus" type="primary" native-type="button">拍照识别</van-button>
                    </Uploader>
                </template> -->
            </van-field>

            <van-field
                v-model="formData.cr_ex3"
                :readonly="isReadonly"
                required
                center
                name="cr_ex3"
                label="预约人身份证"
                placeholder="预约人身份证"
                :rules="[
                    { required: true, message: '请填写预约人身份证' },
                    { validator: validator3, message: '请填写正确的预约人身份证' },
                ]"
            />
            <FieldPopupDatePicker
                v-model:field="formData.gsy_dat3"
                required
                name="gsy_dat3"
                label="出生年月"
                :maxDate="new Date()"
                :readonly="true"
            />
            <van-field
                v-model="formData.cr_ex99"
                :readonly="true"
                type="number"
                required
                center
                name="cr_ex99"
                label="年龄"
                placeholder="年龄"
            />
            <FieldPopupPicker
                v-model:field="formData.cr_ex4"
                :readonly="true"
                required
                name="cr_ex4"
                label="性别"
                :columns="columns3"
            />
            <FieldPopupPicker
                v-model:field="formData.cr_ex5"
                required
                name="cr_ex5"
                label="死亡原因"
                :columns="columns1"
                :readonly="isReadonly"
                :rules="[{ required: true, message: '请选择死亡原因' }]"
            />
            <FieldPopupDatePicker
                v-model:field="formData.gsy_dat1"
                :required="true"
                :maxDate="new Date()"
                name="gsy_dat1"
                label="死亡时间"
                :readonly="isReadonly"
                :rules="[{ required: true, message: '请选择死亡时间' }]"
            />
            <MyTitle>预约上门信息</MyTitle>
            <FieldPopupPicker
                v-model:field="formData.cr_ex6"
                required
                name="cr_ex6"
                label="是否上门办理"
                :columns="columns2"
                :readonly="isReadonly"
                :rules="[{ required: true, message: '请选择是否上门办理' }]"
            />
            <FieldPopupCascader
                required
                :field="gsy_ex100"
                @update:field="gsy_ex100Change"
                name="gsy_ex100"
                label="卫生院"
                :options="columns4"
                confirmType="selectedOptions"
                :readonly="isReadonly"
            />
            <van-field
                v-model="formData.cr_ex7"
                :readonly="isReadonly"
                required
                center
                rows="1"
                autosize
                type="textarea"
                name="cr_ex7"
                label="详细地址"
                placeholder="详细地址"
                :rules="[{ required: true, message: '请填写详细地址' }]"
            />
            <MyTitle>预约火化信息</MyTitle>

            <van-field
                v-model="formData.cr_ex8"
                :readonly="isReadonly"
                required
                center
                rows="1"
                autosize
                type="textarea"
                name="cr_ex8"
                label="接尸地点"
                placeholder="接尸地点"
                :rules="[{ required: true, message: '请填写接尸地点' }]"
            />
            <FieldPopupDatePicker
                :field="formData.gsy_dat4"
                @update:field="gsy_dat4Change"
                :required="true"
                :minDate="new Date()"
                name="gsy_dat4"
                label="接尸日期"
                :readonly="isReadonly"
                :rules="[{ required: true, message: '请选择接尸日期' }]"
            />
            <FieldPopupTimePicker
                v-model:field="formData.gsy_dat2"
                :required="true"
                :minTime="minTime"
                name="gsy_dat2"
                label="接尸时间"
                :readonly="isReadonly"
            />
            <div class="tip" style="background-color: red">
                县殡仪馆遗体接运时间（从殡仪馆出车）调整为每日上午8：00至20：00。
            </div>
            <MyTitle>丧葬用品信息</MyTitle>
            <FieldPopupPicker
                :field="formData.cr_ex9"
                @update:field="cr_ex9Change"
                name="cr_ex9"
                label="纸棺"
                :columns="columns5"
                :readonly="isReadonly"
            />
            <FieldPopupPicker
                :field="formData.cr_ex10"
                @update:field="cr_ex10Change"
                name="cr_ex10"
                label="木棺"
                :columns="columns6"
                :readonly="isReadonly"
            />
            <MyTitle>礼厅(守灵厅)类型</MyTitle>
            <FieldPopupImagePicker v-model:field="formData.cr_ex11" :columns="columns7" label="惠民厅" name="cr_ex11" />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex12"
                :columns="columns8"
                label="普通绢花厅"
                name="cr_ex12"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex13"
                :columns="columns9"
                label="普通鲜花厅"
                name="cr_ex13"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex14"
                :columns="columns10"
                label="中型告别厅"
                name="cr_ex14"
            />
            <MyTitle>延伸服务选择</MyTitle>
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex15"
                :columns="columns11"
                label="遗体穿衣化妆"
                name="cr_ex15"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex16"
                :columns="columns12"
                label="礼厅主持"
                name="cr_ex16"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex17"
                :columns="columns13"
                label="遗体整理"
                name="cr_ex17"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex18"
                :columns="columns14"
                label="遗体铺花"
                name="cr_ex18"
            />
            <FieldPopupImagePicker
                v-model:field="formData.cr_ex19"
                :columns="columns15"
                label="鲜花花束"
                name="cr_ex19"
            />
            <MyTitle>联系人信息</MyTitle>
            <van-field
                v-model="formData.cr_ex21"
                :readonly="isReadonly"
                required
                center
                name="cr_ex21"
                label="联系人"
                placeholder="联系人"
                :rules="[{ required: true, message: '请填写联系人' }]"
            />
            <van-field
                v-model="formData.cr_ex2"
                :readonly="isReadonly"
                required
                center
                type="number"
                maxlength="11"
                name="cr_ex2"
                label="手机号码"
                placeholder="手机号码"
                :rules="[
                    { required: true, message: '请填写手机号码' },
                    { validator: isPhone, message: '请填写正确的手机号码' },
                ]"
            >
                <template #button>
                    <van-button size="small" type="primary" :disabled="hqyzmDis" native-type="button" @click="hqyzm">
                        {{ hqyzmtext }}
                    </van-button>
                </template>
            </van-field>
            <van-field
                v-model="formData.cr_ex22"
                :readonly="isReadonly"
                type="digit"
                required
                center
                name="cr_ex22"
                label="验证码"
                placeholder="验证码"
                :rules="[{ required: true, message: '请填写验证码' }]"
            />
            <van-field
                v-model="formData.cr_ex20"
                :readonly="isReadonly"
                required
                center
                type="number"
                maxlength="11"
                name="cr_ex20"
                label="备用号码"
                placeholder="备用号码"
                :rules="[
                    { required: true, message: '请填写备用号码' },
                    { validator: isPhone, message: '请填写正确的备用号码' },
                ]"
            />
            <FixedButton v-if="!isReadonly" native-type="submit">提交</FixedButton>
        </van-form>
        <van-popup v-model:show="show1" round :style="{ height: '30%', width: '90%' }">
            <div class="popup-title">预约须知</div>
            <div class="popup-content">
                <div>纸棺或者木棺只能选择一种，确定要清空木棺类型？</div>
            </div>
            <div style="display: flex">
                <van-button
                    type="danger"
                    style="border-radius: 0"
                    block
                    @click="
                        formData.cr_ex9 = '';
                        show1 = !show1;
                    "
                >
                    取消
                </van-button>
                <van-button
                    type="primary"
                    style="border-radius: 0"
                    block
                    @click="
                        formData.cr_ex10 = '';
                        show1 = !show1;
                    "
                >
                    确认
                </van-button>
            </div>
        </van-popup>
        <van-popup v-model:show="show2" round :style="{ height: '30%', width: '90%' }">
            <div class="popup-title">预约须知</div>
            <div class="popup-content">
                <div>纸棺或者木棺只能选择一种，确定要清空纸棺类型？</div>
            </div>
            <div style="display: flex">
                <van-button
                    type="danger"
                    style="border-radius: 0"
                    block
                    @click="
                        formData.cr_ex10 = '';
                        show2 = !show2;
                    "
                >
                    取消
                </van-button>
                <van-button
                    type="primary"
                    style="border-radius: 0"
                    block
                    @click="
                        formData.cr_ex9 = '';
                        show2 = !show2;
                    "
                >
                    确认
                </van-button>
            </div>
        </van-popup>
    </div>
</template>

<script lang="ts" setup>
    // import { useWeixinLogin3 } from '@/hooks'
    import { saveCemeteryReserveApi, sendSmsApi } from '@/apis';
    import { isPhone, compressImg, isCardID, getSex, getAge, getBirthDate } from '@/utils';
    import { useStore } from '@/store';
    // 微信授权并且跳转到对应页面
    // useWeixinLogin3('sweepGraveAppointment')
    const router = useRouter();
    const route = useRoute();
    const store = useStore();
    const isReadonly: boolean = false;
    const show1: Ref<boolean> = ref(false);
    const show2: Ref<boolean> = ref(false);
    const m: Ref<number> = ref(60);

    const hqyzmDis: Ref<boolean> = ref(false);
    const hqyzmtext: Ref<string> = ref('获取验证码');
    const columns1: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        { text: '自然死亡', value: '自然死亡' },
        { text: '病故', value: '病故' },
        { text: '交通事故', value: '交通事故' },
        { text: '事故', value: '事故' },
        { text: '刑事案件', value: '刑事案件' },
        { text: '其他', value: '其他' },
    ]);
    const columns2: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        { text: '是', value: '是' },
        { text: '否', value: '否' },
    ]);
    const columns3: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        { text: '男', value: '男' },
        { text: '女', value: '女' },
    ]);
    const columns4: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '灵溪镇',
            value: '灵溪镇',
            children: [
                { text: '苍南县灵溪中心卫生院', value: '苍南县灵溪中心卫生院' },
                { text: '苍南县观美镇卫生院', value: '苍南县观美镇卫生院' },
                { text: '苍南县灵溪中心卫生院凤池分院', value: '苍南县灵溪中心卫生院凤池分院' },
                { text: '苍南县浦亭乡卫生院', value: '苍南县浦亭乡卫生院' },
            ],
        },
        {
            text: '宜山镇',
            value: '宜山镇',
            children: [{ text: '苍南县宜山中心卫生院', value: '苍南县宜山中心卫生院' }],
        },
        {
            text: '霞关镇',
            value: '霞关镇',
            children: [{ text: '苍南县霞关中心卫生院', value: '苍南县霞关中心卫生院' }],
        },
        {
            text: '钱库镇',
            value: '钱库镇',
            children: [
                { text: '苍南县钱库中心卫生院新安分院', value: '苍南县钱库中心卫生院新安分院' },
                { text: '苍南县钱库中心卫生院', value: '苍南县钱库中心卫生院' },
                { text: '苍南县仙居乡卫生院', value: '苍南县仙居乡卫生院' },
                { text: '苍南县括山乡卫生院', value: '苍南县括山乡卫生院' },
            ],
        },
        { text: '藻溪镇', value: '藻溪镇', children: [{ text: '苍南县藻溪镇卫生院', value: '苍南县藻溪镇卫生院' }] },
        {
            text: '矾山镇',
            value: '矾山镇',
            children: [
                { text: '苍南县矾山中心卫生院', value: '苍南县矾山中心卫生院' },
                { text: '苍南县昌禅乡卫生院', value: '苍南县昌禅乡卫生院' },
            ],
        },
        { text: '南宋镇', value: '南宋镇', children: [{ text: '苍南县南宋镇卫生院', value: '苍南县南宋镇卫生院' }] },
        {
            text: '马站镇',
            value: '马站镇',
            children: [
                { text: '苍南县马站中心卫生院', value: '苍南县马站中心卫生院' },
                { text: '苍南县马站镇蒲城卫生院', value: '苍南县马站镇蒲城卫生院' },
                { text: '苍南县渔寮乡卫生院', value: '苍南县渔寮乡卫生院' },
            ],
        },
        { text: '沿浦镇', value: '沿浦镇', children: [{ text: '苍南县沿浦镇卫生院', value: '苍南县沿浦镇卫生院' }] },
        {
            text: '桥墩镇',
            value: '桥墩镇',
            children: [
                { text: '苍南县桥墩中心卫生院', value: '苍南县桥墩中心卫生院' },
                { text: '苍南县腾垟乡卫生院', value: '苍南县腾垟乡卫生院' },
                { text: '苍南县五凤乡卫生院', value: '苍南县五凤乡卫生院' },
            ],
        },
        { text: '莒溪镇', value: '莒溪镇', children: [{ text: '苍南县莒溪镇卫生院', value: '苍南县莒溪镇卫生院' }] },
        {
            text: '赤溪镇',
            value: '赤溪镇',
            children: [
                { text: '苍南县赤溪镇卫生院', value: '苍南县赤溪镇卫生院' },
                { text: '苍南县龙沙乡卫生院', value: '苍南县龙沙乡卫生院' },
                { text: '苍南县中墩乡卫生院', value: '苍南县中墩乡卫生院' },
            ],
        },
        { text: '望里镇', value: '望里镇', children: [{ text: '苍南县望里镇卫生院', value: '苍南县望里镇卫生院' }] },
        {
            text: '金乡镇',
            value: '金乡镇',
            children: [
                { text: '苍南县金乡中心卫生院', value: '苍南县金乡中心卫生院' },
                { text: '苍南县石砰乡卫生院', value: '苍南县石砰乡卫生院' },
            ],
        },
        {
            text: '炎亭镇',
            value: '炎亭镇',
            children: [{ text: '苍南县炎亭中心卫生院', value: '苍南县炎亭中心卫生院' }],
        },
        {
            text: '凤阳乡',
            value: '凤阳乡',
            children: [{ text: '苍南县凤阳中心卫生院', value: '苍南县凤阳中心卫生院' }],
        },
        {
            text: '岱岭乡',
            value: '岱岭乡',
            children: [{ text: '苍南县岱岭畲族乡卫生院', value: '苍南县岱岭畲族乡卫生院' }],
        },
        { text: '大渔镇', value: '大渔镇', children: [{ text: '苍南县大渔镇卫生院', value: '苍南县大渔镇卫生院' }] },
    ]);
    const columns5: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        { text: '自备(0元)', value: '自备(0元)' },
        { text: '普通纸棺(380元)', value: '普通纸棺(380元)' },
        { text: '中档纸棺(580元)', value: '中档纸棺(580元)' },
        { text: '高档纸棺(980元)', value: '高档纸棺(980元)' },
    ]);
    const columns6: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        { text: '普通木棺(680元)', value: '普通木棺(680元)' },
        { text: '中档木棺(1080元)', value: '中档木棺(1080元)' },
        { text: '高档木棺(1680元)', value: '高档木棺(1680元)' },
    ]);
    const columns7: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '遗体洗脸(300元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体洗脸(300元)',
        },
        {
            text: '精致化妆(580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '精致化妆(580元)',
        },
        {
            text: '香薰沐浴SPA(1580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '香薰沐浴SPA(1580元)',
        },
    ]);
    const columns8: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '围棺布置费(380元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '围棺布置费(380元)',
        },
        {
            text: '围棺布置费(580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '围棺布置费(580元)',
        },
    ]);
    const columns9: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '围棺布置费(880元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '围棺布置费(880元)',
        },
    ]);
    const columns10: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '围棺布置费(1800元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '围棺布置费(1800元)',
        },
    ]);
    const columns11: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '遗体洗脸(300元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体洗脸(300元)',
        },
        {
            text: '精致化妆(580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '精致化妆(580元)',
        },
        {
            text: '香薰沐浴SPA(1580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '香薰沐浴SPA(1580元)',
        },
    ]);
    const columns12: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '礼仪主持(160元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '礼仪主持(160元)',
        },
    ]);
    const columns13: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '遗体整理(100元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体整理(100元)',
        },
    ]);
    const columns14: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '遗体铺花(300元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体铺花(300元)',
        },
        {
            text: '遗体铺花(580元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体铺花(580元)',
        },
        {
            text: '遗体铺花(880元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体铺花(880元)',
        },
        {
            text: '遗体铺花(基督)(880元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '遗体铺花(基督)(880元)',
        },
    ]);
    const columns15: Ref<
        {
            text: string;
            value: string;
        }[]
    > = ref([
        {
            text: '鲜花花束(80元)',
            image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
            value: '鲜花花束(80元)',
        },
    ]);
    onBeforeMount(async () => {});

    // let currentTime: any = new Date();
    // currentTime.setHours(currentTime.getHours() + 1);
    // currentTime = currentTime.getHours().toString().padStart(2, '0') + ':00:00';
    const minTime: Ref<any> = ref('00:00:00');

    const gsy_ex100: Ref<string> = ref('');

    const formData = ref({
        cr_ex2: '',
        cr_ex1: '',
        cr_ex3: '',
        cr_ex4: '',
        cr_ex5: '',
        cr_ex6: '',
        cr_ex7: '',
        cr_ex8: '',
        cr_ex9: '',
        cr_ex10: '',
        cr_ex11: '',
        cr_ex12: '',
        cr_ex13: '',
        cr_ex14: '',
        cr_ex15: '',
        cr_ex16: '',
        cr_ex17: '',
        cr_ex18: '',
        cr_ex19: '',
        cr_ex20: '',
        cr_ex21: '',
        cr_ex22: '',

        cr_ex99: '',
        gsy_ex6: '',
        gsy_dat1: '',
        gsy_dat2: '',
        gsy_dat3: '',
        gsy_dat4: '',
        gsy_ex100: '',
        gsy_ex101: '',
    });
    const hqyzm = () => {
        if (!isPhone(formData.value.cr_ex2)) {
            showFailToast('请填写正确的联系方式');
            return false;
        }
        // 获取验证码
        sendSmsApi({
            company: '连云港人文纪念园智慧陵园管理系统',
            dw: '连云港人文纪念园',
            phone: formData.value.cr_ex2,
        }).then((res) => {
            if (res.status == '+OK') {
                showSuccessToast(res.msg);
            } else {
                showFailToast(res[0].msg);
            }
        });

        // 倒计时
        hqyzmtext.value = m.value + 's';
        hqyzmDis.value = true;
        let time = setInterval(() => {
            m.value--;
            hqyzmtext.value = m.value + 's';
            if (m.value == 0) {
                hqyzmtext.value = '获取验证码';
                m.value = 60;
                hqyzmDis.value = false;

                clearInterval(time);
            }
        }, 1000);
    };
    // 校验函数返回 true 表示校验通过，false 表示不通过
    const validator3 = (val) => {
        if (isCardID(val)) {
            return false;
        } else {
            formData.value.cr_ex4 = getSex(val);
            formData.value.cr_ex99 = getAge(val).toString();
            formData.value.gsy_dat3 = getBirthDate(val);
            return true;
        }
    };

    const gsy_ex100Change = (val) => {
        console.log(val);
        if (!val) {
            gsy_ex100.value = '';
            formData.value.gsy_ex100 = '';
            formData.value.gsy_ex101 = '';
        }
        gsy_ex100.value = val[0].value + '/' + val[1].value;
        formData.value.gsy_ex100 = val[0].value;
        formData.value.gsy_ex101 = val[1].value;
        if (!formData.value.cr_ex8) {
            formData.value.cr_ex8 = val[0].value;
        }
    };
    const gsy_dat4Change = (val) => {
        formData.value.gsy_dat4 = val;
        let date = new Date();

        if (
            val.split('-')[0] == date.getFullYear() &&
            val.split('-')[1] == date.getMonth() + 1 &&
            val.split('-')[2] == date.getDate()
        ) {
            date.setHours(date.getHours() + 1);
            minTime.value = date.getHours().toString().padStart(2, '0') + ':00:00';
            console.log(formData.value.gsy_dat2);
            if (formData.value.gsy_dat2 && formData.value.gsy_dat2.split(':')[0] < minTime.value.split(':')[0]) {
                formData.value.gsy_dat2 = '';
            }
        } else {
            minTime.value = '00:00:00';
        }
    };
    const cr_ex9Change = (val) => {
        console.log(val);
        formData.value.cr_ex9 = val;
        if (formData.value.cr_ex10) {
            show1.value = true;
        }
    };
    const cr_ex10Change = (val) => {
        console.log(val);
        formData.value.cr_ex10 = val;
        if (formData.value.cr_ex9) {
            show2.value = true;
        }
    };
    const onFailed = (value) => {
        showDialog({
            title: '提示',
            message: value.errors[0].message,
        });
    };
    const onSubmit = async (value) => {
        showLoadingToast({
            message: '加载中...',
            forbidClick: true,
            duration: 0,
        });

        saveCemeteryReserveApi({
            ...formData.value,
            // data: JSON.stringify(formData.value),
            // gsy_company: store.company,
            // gsy_dw: store.dw,
        })
            .then((res) => {
                closeToast();
                if (res[0].status == '+OK') {
                    showDialog({
                        title: '提示',
                        message: res[0].msg,
                    }).then(() => {
                        router.push('/');
                    });
                } else {
                    showDialog({
                        title: '提示',
                        message: res[0].msg,
                    });
                }
            })
            .catch((err) => {
                closeToast();
                showDialog({
                    title: '提示',
                    message: '网络异常，请稍后重试！',
                });
            });
    };
</script>
<style lang="scss" scoped>
    .repair {
        width: 100vw;
        height: 100vh;
        overflow: auto;
        display: flex;
        flex-direction: column;
    }
    :deep(.van-form) {
        // height: 550px;
        // height: 510px;
        flex: 1;
        overflow: scroll;
    }
    .tip {
        width: 90%;
        margin: auto;
        border-radius: 5px;
        background: #87cefa;
        color: white;
        padding: 10px;
        margin-top: 5px;
        margin-bottom: 5px;
        font-size: 15px;
    }
    .uploader-box {
        border-bottom: 1px solid #999999;
        margin: 6px 15px;
        box-sizing: border-box;
        padding: 0px 0;
        height: 180px;
        overflow: hidden;
        img {
            width: 345px;
            height: 180px;
        }
        // 上传图片后图片大小
        :deep(.van-uploader__preview-image) {
            width: 345px;
            height: 180px;
        }
    }

    :deep(.van-popup) {
        display: flex;
        flex-direction: column;
    }
    .popup-title {
        color: $font-color-global;
        font-size: 18px;
        font-weight: bold;
        padding-top: 10px;
    }
    .popup-content {
        @include padding-global;
        // padding-top: 20px;
        text-indent: 30px;
        text-align: left;
        font-size: 16px;
        padding-bottom: 30px;
        flex: 1;
        overflow: scroll;
    }
</style>
